import 'package:coinbaby/common/textstyle/textstyle.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class ForgetPwdPage extends StatefulWidget {
  @override
  _ForgetPwdPageState createState() => _ForgetPwdPageState();
}

class _ForgetPwdPageState extends State<ForgetPwdPage> {

  final _focusNode = FocusNode();
  final _controller = TextEditingController();

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  void _nextStep() {
    Navigator.pushNamed(context, "/resetpwd");
  }

  @override
  Widget build(BuildContext context) {
    
    final size = MediaQuery.of(context).size;
    final marginH = size.height * 0.06;

    return Scaffold(
      body: GestureDetector(
        behavior: HitTestBehavior.translucent,
        onTap: () => _focusNode.unfocus(),
        child: SafeArea(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              IconButton(
                icon: Icon(Icons.keyboard_arrow_left),
                onPressed: () => Navigator.pop(context),
              ),
              SizedBox(height: marginH),
              Padding(
                padding: const EdgeInsets.all(20),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text("找回密码", style: AppFont.textStyle(26, Colors.black, fontWeight: FontWeight.bold),),
                    SizedBox(height: 10),
                    Padding(
                      padding: const EdgeInsets.only(right: 80),
                      child: Text("为了保证您的账户安全，1天只能操作1次，否则账户将会被锁定无法登录",style: AppFont.textStyle(14, Colors.grey),),
                    ),
                    SizedBox(height: marginH),
                    TextField(
                      inputFormatters: [WhitelistingTextInputFormatter.digitsOnly],
                      keyboardType: TextInputType.number,
                      maxLength: 11,
                      focusNode: _focusNode,
                      controller: _controller,
                      decoration: InputDecoration(
                        hintText: "请输入手机号码",
                        counterText: "", // 删除输入长度限制
                        prefixIcon: Row(
                          mainAxisSize: MainAxisSize.min,
                          children: <Widget>[
                            Text("+86"),
                            Icon(Icons.arrow_drop_down)
                          ],
                        ),
                        labelStyle: AppFont.textStyle(14, const Color(0xff101010))
                      ),
                    ),

                    SizedBox(height: marginH),
                    InkWell(
                      onTap: _nextStep,
                      child: Container(
                        width: size.width,
                        height: 50,
                        margin: const EdgeInsets.only(top: 35),
                        decoration: BoxDecoration(
                          color: Colors.red,
                          borderRadius: BorderRadius.circular(10)
                        ),
                        alignment: Alignment.center,
                        child: Text("下一步", style: AppFont.textStyle(14, Colors.white),),
                      ),
                    ),
                  ],
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}